#include "dialog.h"
#include "ui_dialog.h"

#include <QInputDialog>

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}


void Dialog::on_pushButton_clicked()
{
  bool ok;
  QString  strTest=QInputDialog::getText(this, tr("标准输入对话框"),
                                         tr("请输入学号："), QLineEdit::Normal,
                                         ui->lineEdit->text(), &ok);

  if(ok && !strTest.isEmpty())
  {
      ui->lineEdit->setText(strTest);
  }

}

void Dialog::on_pushButton_3_clicked()
{
    QStringList list1;
    list1<<"男"<<"女";
    bool ok;
//                                   getItem(QWidget *parent, const QString &title, const QString &label, const QStringList &items, int current = 0, bool editable = true, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), Qt::InputMethodHints inputMethodHints = Qt::ImhNone
    QString strsexItem=QInputDialog::getItem(this,"标准输入框","请输入性别",list1,0,true,&ok);

    if(ok&&!strsexItem.isEmpty())
    {
        ui->lineEdit_3->setText(strsexItem);
    }

}
